home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / binutils.7 / binutils / binutils-2.7 / ld / scripttempl / nw.sc < prev    next >
Encoding:
Text File  |  1996-07-04  |  5.0 KB  |  132 lines

  1. #
  2. # Unusual variables checked by this code:
  3. #    NOP - two byte opcode for no-op (defaults to 0)
  4. #    DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
  5. #    OTHER_READONLY_SECTIONS - other than .text .init .ctors .rodata ...
  6. #        (e.g., .PARISC.milli)
  7. #    OTHER_READWRITE_SECTIONS - other than .data .bss .sdata ...
  8. #        (e.g., .PARISC.global)
  9. #    OTHER_SECTIONS - at the end
  10. #    EXECUTABLE_SYMBOLS - symbols that must be defined for an
  11. #        executable (e.g., _DYNAMIC_LINK)
  12. #    TEXT_START_SYMBOLS - symbols that appear at the start of the
  13. #        .text section.
  14. #    DATA_START_SYMBOLS - symbols that appear at the start of the
  15. #        .data section.
  16. #    OTHER_BSS_SYMBOLS - symbols that appear at the start of the
  17. #        .bss section besides __bss_start.
  18. #    DATA_PLT - .plt should be in data segment, not text segment.
  19. #
  20. # When adding sections, do note that the names of some sections are used
  21. # when specifying the start address of the next.
  22. #
  23. test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
  24. test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
  25. test "$LD_FLAG" = "N" && DATA_ADDR=.
  26. INTERP=".interp   ${RELOCATING-0} : { *(.interp)     }"
  27. PLT=".plt    ${RELOCATING-0} : { *(.plt)    }"
  28. cat <<EOF
  29. OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
  30.           "${LITTLE_OUTPUT_FORMAT}")
  31. OUTPUT_ARCH(${ARCH})
  32.  
  33. ${RELOCATING+${LIB_SEARCH_DIRS}}
  34. ${RELOCATING+/* Do we need any of these for elf?
  35.    __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}}  */}
  36. ${RELOCATING+${EXECUTABLE_SYMBOLS}}
  37. ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
  38.   if gld -r is used and the intermediate file has sections starting
  39.   at non-zero addresses.  Could be a Solaris ld bug, could be a GNU ld
  40.   bug.  But for now assigning the zero vmas works.  */}
  41. SECTIONS
  42. {
  43.   /* Read-only sections, merged into text segment: */
  44.   ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_START_ADDR} + SIZEOF_HEADERS;}}
  45.   ${CREATE_SHLIB+${RELOCATING+. = SIZEOF_HEADERS;}}
  46.   ${CREATE_SHLIB-${INTERP}}
  47.   .hash        ${RELOCATING-0} : { *(.hash)        }
  48.   .dynsym      ${RELOCATING-0} : { *(.dynsym)        }
  49.   .dynstr      ${RELOCATING-0} : { *(.dynstr)        }
  50.   .rel.text    ${RELOCATING-0} : { *(.rel.text)        }
  51.   .rela.text   ${RELOCATING-0} : { *(.rela.text)     }
  52.   .rel.data    ${RELOCATING-0} : { *(.rel.data)        }
  53.   .rela.data   ${RELOCATING-0} : { *(.rela.data)     }
  54.   .rel.rodata  ${RELOCATING-0} : { *(.rel.rodata)     }
  55.   .rela.rodata ${RELOCATING-0} : { *(.rela.rodata)     }
  56.   .rel.got     ${RELOCATING-0} : { *(.rel.got)        }
  57.   .rela.got    ${RELOCATING-0} : { *(.rela.got)        }
  58.   .rel.ctors   ${RELOCATING-0} : { *(.rel.ctors)    }
  59.   .rela.ctors  ${RELOCATING-0} : { *(.rela.ctors)    }
  60.   .rel.dtors   ${RELOCATING-0} : { *(.rel.dtors)    }
  61.   .rela.dtors  ${RELOCATING-0} : { *(.rela.dtors)    }
  62.   .rel.bss     ${RELOCATING-0} : { *(.rel.bss)        }
  63.   .rela.bss    ${RELOCATING-0} : { *(.rela.bss)        }
  64.   .rel.plt     ${RELOCATING-0} : { *(.rel.plt)        }
  65.   .rela.plt    ${RELOCATING-0} : { *(.rela.plt)        }
  66.   .init        ${RELOCATING-0} : { *(.init)    } =${NOP-0}
  67.   ${DATA_PLT-${PLT}}
  68.   .text    ${RELOCATING-0} :
  69.   {
  70.     ${RELOCATING+${TEXT_START_SYMBOLS}}
  71.     *(.text)
  72.     ${CONSTRUCTING+    __CTOR_LIST__ = .;}
  73.     ${CONSTRUCTING+    LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)}
  74.     ${CONSTRUCTING+    *(.ctors)}
  75.     ${CONSTRUCTING+    LONG(0)}
  76.     ${CONSTRUCTING+    __CTOR_END__ = .;}
  77.     ${CONSTRUCTING+    __DTOR_LIST__ = .;}
  78.     ${CONSTRUCTING+    LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)}
  79.     ${CONSTRUCTING+    *(.dtors)}
  80.     ${CONSTRUCTING+    LONG(0)}
  81.     ${CONSTRUCTING+    __DTOR_END__ = .;}
  82.   }
  83.   ${RELOCATING+_etext = .;}
  84.   ${RELOCATING+PROVIDE (etext = .);}
  85.   .fini    ${RELOCATING-0} : { *(.fini)    } =${NOP-0}
  86.   .ctors   ${RELOCATING-0} : { *(.ctors)   }
  87.   .dtors   ${RELOCATING-0} : { *(.dtors)   }
  88.   .rodata  ${RELOCATING-0} : { *(.rodata)  }
  89.   .rodata1 ${RELOCATING-0} : { *(.rodata1) }
  90.   ${RELOCATING+${OTHER_READONLY_SECTIONS}}
  91.  
  92.   /* Read-write section, merged into data segment: */
  93.   ${RELOCATING+. = ${DATA_ADDR- ALIGN(8) + ${MAXPAGESIZE}};}
  94.   .data  ${RELOCATING-0} :
  95.   {
  96.     ${RELOCATING+${DATA_START_SYMBOLS}}
  97.     *(.data)
  98.     ${CONSTRUCTING+CONSTRUCTORS}
  99.   }
  100.   .data1 ${RELOCATING-0} : { *(.data1) }
  101.   ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
  102.   .got         ${RELOCATING-0} : { *(.got.plt) *(.got) }
  103.   .dynamic     ${RELOCATING-0} : { *(.dynamic) }
  104.   ${DATA_PLT+${PLT}}
  105.   /* We want the small data sections together, so single-instruction offsets
  106.      can access them all, and initialized data all before uninitialized, so
  107.      we can shorten the on-disk segment size.  */
  108.   .sdata   ${RELOCATING-0} : { *(.sdata) }
  109.   ${RELOCATING+_edata  =  .;}
  110.   ${RELOCATING+PROVIDE (edata = .);}
  111.   ${RELOCATING+__bss_start = .;}
  112.   ${RELOCATING+${OTHER_BSS_SYMBOLS}}
  113.   .sbss    ${RELOCATING-0} : { *(.sbss) *(.scommon) }
  114.   .bss     ${RELOCATING-0} :
  115.   {
  116.    *(.dynbss)
  117.    *(.bss)
  118.    *(COMMON)
  119.   }
  120.   ${RELOCATING+_end = . ;}
  121.   ${RELOCATING+PROVIDE (end = .);}
  122.  
  123.   /* These are needed for ELF backends which have not yet been
  124.      converted to the new style linker.  */
  125.   .stab 0 : { *(.stab) }
  126.   .stabstr 0 : { *(.stabstr) }
  127.  
  128.   /* These must appear regardless of ${RELOCATING}.  */
  129.   ${OTHER_SECTIONS}
  130. }
  131. EOF
  132.